//
//  MOProductCell.m
//  FastDoctor
//
//  Created by 冯龙飞 on 16/5/21.
//  Copyright © 2016年 冯龙飞. All rights reserved.
//

#import "MOProductCell.h"
#import "Masonry.h"

@interface MOProductCell ()

@property(nonatomic, strong) UIView * linwView;

@end

// 这个自定义方法是用来添加cell中的下划线,并且重新约束imageview
@implementation MOProductCell

- (void)awakeFromNib {
    // Initialization code
}

// 在初始化方法中添加下划线视图
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.linwView.backgroundColor = [UIColor lightGrayColor];
        [self addSubview:self.linwView];
    }
    return self;
}

// 在这个方法中约束下划线,并且重新给系统的imageview修改尺寸
- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    [self.linwView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.bottom.equalTo(self);
        make.height.equalTo(@1);
        make.width.equalTo(self);
        make.left.equalTo(self).offset(15);
        
    }];
    
    // 重新布局imageview的大小和位置(因为给的图片有点大)
    [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self);
        make.width.equalTo(@17);
        make.height.equalTo(@17);
        
    }];
   
}

// 懒加载一个下划线视图
- (UIView *)linwView {
    
    if (_linwView == nil) {
        
        _linwView = [[UIView alloc]init];
        
    }
    return _linwView;
}

@end
